package com.example.huainanlive.adapter

import android.view.View
import android.widget.ImageView
import android.widget.TextView
import coil.load
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.huainanlive.R
import com.example.huainanlive.bean.GetCommentItem

class LivePlayAdapter : BaseQuickAdapter<GetCommentItem, BaseViewHolder>(R.layout.item_rv_live) {
    override fun convert(holder: BaseViewHolder, item: GetCommentItem) {

        holder.getViewOrNull<TextView>(R.id.people_name)?.text = item.nickName
        holder.getViewOrNull<TextView>(R.id.people_time)?.text = item.createTime

        if (item.msg.isNullOrEmpty()) {
            holder.getViewOrNull<TextView>(R.id.people_msg)?.visibility = View.GONE
        } else {
            holder.getViewOrNull<TextView>(R.id.people_msg)?.text = item.msg
            holder.getViewOrNull<TextView>(R.id.people_msg)?.visibility = View.VISIBLE
        }

        if (item.headImg.isNullOrEmpty()) {
            holder.getViewOrNull<ImageView>(R.id.people_img)?.visibility = View.GONE
        } else {
            holder.getViewOrNull<ImageView>(R.id.people_img)?.visibility = View.VISIBLE
            holder.getViewOrNull<ImageView>(R.id.people_img)?.load(item.headImg)

        }

    }
}